﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Summary description for ProductDAO
/// </summary>
public class ProductDAO
{
    /*
     * Option 1 : Disconnect UnType  
     */
    public static DataTable GetAllProducts()
    {
        DataTable dt = null;
        try
        {
            SqlConnection cnn = DatabaseInteraction.GetConnection();
            SqlCommand command = new SqlCommand(DatabaseInteraction.SelectProduct, cnn);
            dt = new DataTable();
            SqlDataAdapter adt = new SqlDataAdapter();
            adt.SelectCommand = command;
            adt.Fill(dt);
        }
        catch (Exception)
        {

            return null;
        }
        return dt;
    }

    /*
     * Option  2 : Disconnected Type
    
     */
    public static DataTable GetAllProductsType()
    {
        NorthwindDatasetTableAdapters.ProductsTableAdapter adt = new NorthwindDatasetTableAdapters.ProductsTableAdapter();
        NorthwindDataset.ProductsDataTable tb = new NorthwindDataset.ProductsDataTable();
        adt.Fill(tb);
        return tb;
    }


}